<!--包含头部文件-->
{include file="public/header" /}
<style>
    #inputBox{
        width: 100%;
        height: 40px;
        border: 1px solid cornflowerblue;
        color: cornflowerblue;
        border-radius: 20px;
        position: relative;
        text-align: center;
        line-height: 40px;
        overflow: hidden;
        font-size: 16px;
    }
    #inputBox input{
        width: 114%;
        height: 40px;
        opacity: 0;
        cursor: pointer;
        position: absolute;
        top: 0;
        left: -14%;
    }
    #imgBox{
        text-align: left;
    }
    .imgContainer{
        display: inline-block;
        width: 32%;
        height: 150px;
        margin-left: 1%;
        border: 1px solid #666666;
        position: relative;
        margin-top: 30px;
        box-sizing: border-box;
    }
    .imgContainer img{
        width: 100%;
        height: 150px;
        cursor: pointer;
    }
    .imgContainer p{
        position: absolute;
        bottom: -1px;
        left: 0;
        width: 100%;
        height: 30px;
        background: black;
        text-align: center;
        line-height: 30px;
        color: white;
        font-size: 16px;
        font-weight: bold;
        cursor: pointer;
        display: none;
    }
    .imgContainer:hover p{
        display: block;
    }
</style>
<body>
<article class="page-container">
    <form class="form form-horizontal" action="" method="post" id="form-stock-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>运单号：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="" placeholder="请输入物流单号" id="express_num" name="express_num"/>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;搜索&nbsp;&nbsp;">
                <!--<input class="btn btn-primary radius" id="sdlr" onclick="entering()" type="button" value="&nbsp;&nbsp;手动录入&nbsp;&nbsp;">-->
            </div>
        </div>
    </form>
    <div class="form-horizontal" id="goods_info">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品信息：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <table class="table">
                    <tr>
                        <th rowspan="3" width="20%"><img src="http://img.alicdn.com/imgextra/i4/TB1mIBSOXXXXXb7aXXXXXXXXXXX_!!0-item_pic.jpg" alt=""height="150px" width="150px"></th>
                        <th>商品名：衣之纯2017秋冬新款高领毛衣女 韩版宽松加厚蝙蝠袖打底衫</th>
                    </tr>
                    <tr>
                        <td>规格：M 黑色</td>
                    </tr>
                    <tr>
                        <td>收货店铺：</td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input type="hidden" value="" name="member_task" id="member_task">
                <input class="btn btn-primary radius" type="submit"  onclick="submit()" value="&nbsp;&nbsp;入库&nbsp;&nbsp;">
                <input class="btn btn-primary radius" type="submit" onclick="clos()" value="&nbsp;&nbsp;关闭&nbsp;&nbsp;">
            </div>
        </div>
    </div>

</article>

<!--包含footer文件-->
{include file="public/footer" /}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__STATIC__/js/uploadImg.js"></script>

<script type="text/javascript">

    imgUpload({
        inputId:'file', //input框id
        imgBox:'imgBox', //图片容器id
        buttonId:'btn', //提交按钮id
        upUrl:'php/imgFile.php',  //提交地址
        data:'file1', //参数名
        num:"5"//上传个数
    })

    /*地图定位*/
    function map(title, url, w, h) {
        layer_show(title, url, w, h);
    }
    
    function entering() {
        var html = '';
         html += '<form class="form form-horizontal" action="" method="post" id="form-stock-add">'+
            '<div class="row cl">'+
        '<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品名：</label>'+
        '<div class="formControls col-xs-5 col-sm-5">'+
        '<input type="text" class="input-text" value="" placeholder="" id="goods_name" name="goods_name"/>'+
        '</div>'+
        '</div>'+
        '<div class="row cl">'+
        '<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">'+
        '<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;搜索&nbsp;&nbsp;">'+
        '<input class="btn btn-primary radius" id="sdlr" onclick="entering()" type="button" value="&nbsp;&nbsp;手动录入&nbsp;&nbsp;">'+
        '</div>'+
        '</div>'+
        '</form>';
        $("#goods_info").html(html)
        
    }

    function submit() {
        var member_task = 0;
        member_task = $("#member_task").val();
        if (member_task >0){
            $.ajax({
                url:"{:url('shop/ajax_finish')}",
                type:"post",
                data:{'member_task':member_task},
                async: true,
                processData: false,
                contentType: false,
                dataType:"json",
                success:function (data) {
                    if (data.code == 200){
                        layer.alert('入库成功',{
                            skin: 'layui-layer-molv' //样式类名 自定义样式
                            ,closeBtn: 0  // 是否显示关闭按钮
                            ,anim: 1 //动画类型
                            ,btn: '确认'//按钮
                            ,icon: 6  // icon
                            ,yes:function(){
                                layer.closeAll();
                                parent.location.reload();
                            }
                        })

                    }else {
                        layer.alert('入库失败'+data.msg+'',{
                            skin: 'layui-layer-molv' //样式类名 自定义样式
                            ,closeBtn: 0  // 是否显示关闭按钮
                            ,anim: 1 //动画类型
                            ,btn: '确认'//按钮
                            ,icon: 6  // icon
                            ,yes:function(){
                                layer.closeAll();
                                parent.location.reload();
                            }
                        })
                    }

                },
                error:function () {
                    alert("添加失败")
                    return false;
                }
            })
        }

    }

    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-stock-add").validate({
            rules:{
                express_num:{
                    required:true,
                },
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                // var arr = $('#form-shop-add').serialize();
                var arr = new FormData(document.getElementById("form-stock-add"));
                $.ajax({
                    url:"{:url('shop/ajax_get_goodsinfo')}",
                    type:"post",
                    data:arr,
                    async: true,
                    processData: false,
                    contentType: false,
                    dataType:"json",
                    success:function (data) {
                        if (data.code == 200){
                            var  html = '';
                        html += '<div class="row cl">' +
                                '<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品信息：</label>' +
                            '<div class="formControls col-xs-8 col-sm-9">' +
                                '<table class="table">'+
                                '<tr>' +
                                '<th rowspan="3" width="20%"><img src="'+ data.data.img_url +'" alt=""height="150px" width="150px"></th>' +
                                '<th>商品名：'+ data.data.goods_name +'</th>'+
                            '</tr>' +
                            '<tr>' +
                            '<td>规格：'+ data.data.spec_name +'</td>' +
                            '</tr>' +
                            '<tr>' +
                            '<td>收货店铺：'+ data.data.shop_name +'</td>' +
                            '</tr>' +
                            '</table>' +
                            '</div>' +
                            '</div>' ;
                        $("#goods_info").html(html)

                        }else {
                            layer.alert('添加失败'+data.msg+'',{
                                skin: 'layui-layer-molv' //样式类名 自定义样式
                                ,closeBtn: 0  // 是否显示关闭按钮
                                ,anim: 1 //动画类型
                                ,btn: '确认'//按钮
                                ,icon: 6  // icon
                                ,yes:function(){
                                    layer.closeAll();
                                    parent.location.reload();
                                }
                            })
                        }

                    },
                    error:function () {
                        alert("添加失败")
                        return false;
                    }
                })

            }
        });

    });
</script>

<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>